<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <link rel="stylesheet" href="../css/eui.css">
</head>
<body>
<div id="app">
    <h1 align="center">用户登陆</h1>
    <el-card style="width: 600px;height: 300px;
    margin: 0 auto;background-color: rgba(255,255,255,0.3)">
        <el-form style="width: 400px;margin: 30px auto" label-width="60px" >
            <el-form-item label="用户名">
                <el-input type="text" v-model="user.username" placeholder="请输入用户名"></el-input>
            </el-form-item>
            <el-form-item label="密码">
                <el-input type="password" v-model="user.password" placeholder="请输入密码"
                          @keyup.enter.native="login"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button style="position: relative;right: 35px" type="primary" @click="login">登录</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</div>
</body>
<script src="../js/vue.js"></script>
<script src="../js/eui.js"></script>
<script src="../js/axios.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function() {
            return {
                user:{
                    id:"",
                    username:"",
                    password:""
                }
            }
        },
        methods:{
            login(){
                if(v.username===""||v.password===""){
                    v.$message.error("用户名或密码不能为空!");
                }
                axios.post("/demo/request/dl",v.user).then(function (response) {
                    let resp=response.data;
                    user=resp.data;
                    if (resp.state===200){
                        v.user=resp.data;
                        location.href="/demo/request/fsqq?id="+v.user.id+"&username="+v.user.username;
                    }else if (resp.state===406){
                        v.$message.error(resp.message);
                    }else if(resp.state===404){
                        v.$message.error(resp.message);
                    }else if(resp.state===409){
                        v.$message.error(resp.message);
                    }
                })
            }
        }
    })
</script>
</html>